--[[ 编码: WMS-28-02 名称: 盘点单-删除后 作者:HAN 日期:2025-1-29 级别:固定 (说明本段代码在项目中不太会变化) 函数: AfterDataObjDelete 功能: -- 如果盘点单的业务状态 =1 (未完成) -- 删除后需要把容器的盘点锁取消, 计划盘点容器里的 盘点单号 清空 更改记录: --]] wms_base = require ("wms_base") function AfterDataObjDelete ( strLuaDEID ) local nRet, strRetInfo nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "N_B_STATE","S_CP_NO","S_COUNT_NO","N_COUNT_NUM","N_ACC_FINISH" ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end local obj_attrs = json.decode( strRetInfo ) local b_state = lua.Get_NumAttrValue( obj_attrs[1].value ) local cp_no = lua.Get_StrAttrValue( obj_attrs[2].value ) local count_no = lua.Get_StrAttrValue( obj_attrs[3].value ) local count_num = lua.Get_NumAttrValue( obj_attrs[4].value ) local finish_num = lua.Get_NumAttrValue( obj_attrs[5].value ) -- 1 盘点单执行中,盘点单相关的盘点容器锁定 if ( b_state == 1 ) then -- 如果有盘点计划单号 if ( cp_no ~= '' ) then local strSetSQL, strCondition, str_where strCondition = "S_CP_NO = '"..cp_no.."' AND S_COUNT_NO = '"..count_no.."'" strSetSQL = "S_COUNT_NO = '', N_B_STATE = 0 " nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "CP_Count_Container", strCondition, strSetSQL) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "设置【计划盘点容器】信息失败!"..strRetInfo) end -- 盘点计划中 累计盘点容器数量减 if ( count_num > finish_num ) then strCondition = "S_CP_NO = '"..cp_no.."'" nRet, strRetInfo = mobox.decDataObjAccQty( strLuaDEID, "Count_Plan", strCondition, "N_ACC_COUNT", count_num-finish_num ) -- if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "decDataObjAccQty(Count_Plan)失败! "..strRetInfo ) end end end --V2.0 nRet, strRetInfo = wms.wms_UnlockCntrByTrans( strLuaDEID, count_no ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "盘点单'"..count_no.."'解容器锁失败!"..strRetInfo ) end if ( cp_no == '' ) then -- 说明盘点单不是通过盘点计划创建的,这个时候盘点容器和盘点单直接相关,删除盘点单的时候需要删除盘点容器 local strCondition = "S_COUNT_NO = '"..count_no.."'" nRet, strRetInfo = mobox.deleteDataObject( strLuaDEID, "CP_Count_Container", strCondition ) if ( nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除盘点单相关的【计划盘点容器】失败! "..strRetInfo ) end end end end